//package com.zhaoyd.uaademo.config.security;
//
//import com.zhaoyd.uaademo.entity.SysResource;
//import com.zhaoyd.uaademo.entity.SysRole;
//import com.zhaoyd.uaademo.entity.SysUser;
//import com.zhaoyd.uaademo.enums.ResourceTypeEnum;
//import com.zhaoyd.uaademo.service.SysResourceService;
//import com.zhaoyd.uaademo.service.SysRoleService;
//import com.zhaoyd.uaademo.service.SysUserService;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//
///**
// * @author zhaoyd
// * @date 2020-10-31 19:44
// */
//@Component
//public class MyUserDetailService implements UserDetailsService {
//    @Resource
//    private SysUserService sysUserService;
//    @Resource
//    private SysRoleService sysRoleService;
//    @Resource
//    private SysResourceService sysResourceService;
//    @Override
//    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//        SysUser sysUser = sysUserService.findByUsername(username);
//        if(sysUser == null){
//            throw new UsernameNotFoundException(username);
//        }
//        Set<String> roleCodes = sysRoleService.listRoleCodeByUser(sysUser.getId());
//        Set<String> resourceCodes = sysResourceService.listResourceCodeByUser(sysUser.getId());
//
//
//        return MyUserDetail.build(sysUser, roleCodes, resourceCodes);
//    }
//}
